using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace Konst3d.Efficiency
{
    public class NullBinaryEncoder : ICryptographicEngine
    {
        #region Constructor

        public NullBinaryEncoder(Encoding encoding)
        {
            Contract.Requires(encoding != null);
            Encoding = encoding;
        }

        #endregion // Constructor

        #region ICryptographicEngine Members

        public Encoding Encoding
        {
            get;
            private set;
        }

        public int GetLength(string text)
        {
            return Encoding.GetByteCount(text);
        }

        public byte[] Encode(string text)
        {
            return Encoding.GetBytes(text);
        }

        public string Decode(byte[] data)
        {
            return Encoding.GetString(data);
        }

        public string Decode(byte[] data, int offset, int length)
        {
            return Encoding.GetString(data, offset, length);
        }

        #endregion

        #region Overrides

        public override string ToString()
        {
            return "No encoding";
        }

        #endregion // Overrides
    }
}
